// pages/store/store.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    navTitle:['新增商品','全部商品'],
    activeIndex:0
  },

  onShow(){
    let phoneNumber = wx.getStorageSync('userInfo').account
    let storeInfo = wx.getStorageSync('storeInfo')

    if(storeInfo.length != 0){
      this.setData({
        storeInfo,
      })
    }else{
      wx.cloud.callFunction({
        name:'getStoreInfo',
        data:{
          phoneNumber,
        }
      }).then(res=>{
        this.setData({
          storeInfo:res.result.data[0]
        })
        wx.setStorageSync('storeInfo', res.result.data[0])
      })
    }


  },

  changeToActive(e){
    this.setData({
      activeIndex:e.currentTarget.id
    })
  },

  changePages(e){
    this.setData({
      activeIndex:e.detail.currentItemId
    })
  },

  //编辑店铺信息
  modify(){
    wx.navigateTo({
      url: '/pages/storeInfo/storeInfo',
    })
  }
})